package com.y2w.gulimall.order.vo;

import com.sun.org.apache.xpath.internal.operations.Bool;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class OrderConfirmVo {
    /*收货地址列表*/
    @Getter
    @Setter
    List<MemberAddressVo> address;

    /*所有选中的购物项*/
    @Getter
    @Setter
    List<OrderItemVo> items;

    /*发票信息*/

    /*优惠券信息*/
    @Getter
    @Setter
    Integer integration;

    //防重令牌
    @Setter@Getter
    String orderToken;
    @Setter@Getter
    Map<Long, Boolean> stocks;

    public BigDecimal getTotal() { //订单总额
        BigDecimal sum =new BigDecimal(0);
        if (items != null) {
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount()));
                sum=sum.add(multiply);
            }
        }
        return sum;
    }
    public BigDecimal getPayPrice() {  //应付价格
        BigDecimal sum =new BigDecimal(0);
        if (items != null) {
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount()));
                sum=sum.add(multiply);
            }
        }
        return sum;
    }

    public Integer getCount(){
        Integer sum =0;
        if (items != null) {
            for (OrderItemVo item : items) {
                sum+=item.getCount();

            }
        }
        return sum;
    }


}
